import 'package:flutter/material.dart';
import 'package:mortgageCalculator/modal/tab.dart';
import 'package:mortgageCalculator/page/sy.dart';
import 'package:mortgageCalculator/page/zh.dart';

import 'gjj.dart';

class IndexPage extends StatelessWidget {
  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    //初始化标签
    List<Widget> tabs = [
      _renderTab(new Text("商业贷款")),
      _renderTab(new Text("公积金贷款"))
    ];
    //一个控件，可以监听返回键
    return new WillPopScope(
      child: new TabBarWidget(
          title: new Text("2020房贷计算器"),
          type: TabBarWidget.TOP_TAB,
          tabItems: tabs,
          tabViews: [new SyPage(), new GjjPage()],
          indicatorColor: Colors.white),
    );
  }

  _renderTab(text) {
    //返回一个标签
    return new Tab(
        child: new Container(
      //设置paddingTop为6
      padding: new EdgeInsets.only(top: 6),
      //一个列控件
      child: new Column(
        //竖直方向居中
        mainAxisAlignment: MainAxisAlignment.center,
        //水平方向居中
        crossAxisAlignment: CrossAxisAlignment.center,
        children: <Widget>[text],
      ),
    ));
  }
}
